package com.code.leetcode.idea;

public class LeetCodeIdea026 {
    public static void main(String[] args) {
//        String s = "()[]{}";
        int[] nums = new int[]{1,1,2};
        LeetCodeIdea026 leetCodeIdea026 = new LeetCodeIdea026();
        int length = leetCodeIdea026.removeDuplicates(nums);
        System.out.println(length);

    }
    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int p=0,q=1;
        while (q < nums.length) {
            if (nums[p] != nums[q]) {
                nums[p+1] = nums[q];
                p++;
            }
            q++;
        }
        return p+1;
    }
}
